Like shroud_cutout_sprite, but the hole can also be turned: `angle` rotates the mask in place, in degrees - 0 is east, turning counterclockwise, the same convention this instance’s own `angle` already uses.
Works differently on Game Boy - The Game Boy makes a dark room darker and keeps the sprites near a light in their own shades; it cannot light the picture, which has one set of shades. Up to 4 lights. The turned shape tells which sprites are near.
Works differently on Game Boy Color - The Game Boy Color darkens a dark room and lights the 8 by 8 pixel squares whose middle is under the turned shape (4 by 4 pixel blocks, whole degrees). Up to 4 lights, no flicker, a picture of 3 palettes at most and 4 sprite palettes at most.
Works differently on Sega Genesis - The Sega Genesis has one dark level: half as bright as the picture. Every darkness number above 0 shows that same dark (a room set to 72 is no darker than one set to 50), and 0 is no dark at all. A light made from code (shroud_cutout, shroud_cutout_sprite, shroud_cutout_sprite_angle) cuts its hole in that dark. The hole is a picture made ahead of time from the circle or from the sprite the call names, so the sprite's name must be written in the call (not chosen while the game plays), a size or a direction the code works out while the game plays is shown as the nearest one made (six sizes from half to double, sixteen directions), and a size or direction written as a number is exact. Each picture takes cartridge space and some of the picture chip's sprites (the build says how many and refuses a set of lights the chip cannot hold). An object stands in the light as a whole while its middle is in the light, and a light near the edge of the screen is whole or gone.
On other consoles this differs: see Side by side and How the consoles differ.
shroud_cutout_sprite_angle(mask, scale, flicker, angle)| Name | Type |
|---|---|
mask | sprite |
scale | real |
flicker | bool |
angle | real |
Nothing.
shroud_cutout_sprite, plus one more thing: the hole can turn. angle rotates the mask in place, using the same angle convention as everywhere else in this manual - 0 is straight east, turning counterclockwise from there. Hand it the same number you use to aim a gun or face a character, and the light turns to match - once, at that instant (see "The angle is taken once, not tracked" below).
Everything else works exactly like shroud_cutout_sprite: scale sizes the mask the same way, flicker pulses that size the same way, and it is inert in a room that is not shrouded. Calling any of the three attach functions again replaces this instance's whole light, angle included - shroud_cutout(0, false) is still the one way to turn a light off.
shroud_cutout_sprite already has three arguments. Adding angle as a fourth, optional one was considered and turned down: an optional argument reads fine once you already know the whole call, but it is one more thing to puzzle over the first time you meet it, and a signature that just says what it needs is worth more than saving one function name. So this is its own call instead, with shroud_cutout_sprite's own three arguments kept in their exact order - turning an existing call into this one is just "add angle at the end, and change the name," nothing else moves.
This is worth knowing before you draw the mask, not after.
The GBA can only ever show a rotated (or scaled) sprite at up to double the size it was drawn at. Draw your mask 32x32 pixels, and it can turn to any angle and still show completely, right up to a 64x64 area on screen. Ask it to show anything past that - by drawing a bigger shape than fits, or by combining a large scale with the turn - and the extra is cut off by the hardware itself. Not by this engine, and not with an error: it simply is not there.
This is the same rule behind every rotated or scaled sprite on this hardware, not something special about lights - see Budgets for the matrix-cost side of it. The ceiling is fixed either way: 64x64 is the biggest a sprite can be drawn at all, so 128x128 is the largest a turning, scaled mask could ever show, no matter how it is drawn.
Handing this call an angle does not link the light to it. angle is a plain number, copied the instant you call this and never looked at again until you call this again. It makes no difference whether you passed a literal number or this instance's own angle field - the light does not know where the number came from, and it never checks back.
So one call in Create points the cone wherever this instance happened to be facing at that exact moment, then leaves it there. If the instance keeps turning afterward, the cone does not turn with it - it stays aimed at the old angle until something calls this again.
For a light that should follow a turning character, call this again every frame with the current angle - typically from Step, right after whatever code turns the instance. The second example below does exactly that, adapted from examples/lighting's own flashlight.
The light's position is different: it follows the instance on its own, every frame, forever, exactly like shroud_cutout_sprite - no repeated call needed for that part. Only the angle needs asking again.
shroud_cutout_sprite_angle(spr_doc_flashlight_mask, 1.7, false, angle);A flashlight cone, aimed wherever this instance is facing the moment it is created - and no further, even once the instance turns. Fine for a light that never needs to turn, like a torch fixed to a wall.
if (btn_held(BTN_L)) { angle += 3; }
if (btn_held(BTN_R)) { angle -= 3; }
shroud_cutout_sprite_angle(spr_doc_flashlight_mask, 1.7, false, angle);The real flashlight pattern, from Step: turn angle however this instance turns, then call shroud_cutout_sprite_angle again with the new value - every step, not only once. That repeated call is what actually keeps the cone pointed the way the instance is facing.
Turning a light costs nothing beyond what shroud_cutout_sprite already spends: a scaled hole already needs one of the console's rotation-and-scaling slots, and turning it shares that exact same slot rather than needing a second one. See Budgets for the pool every rotated or scaled sprite in a room draws from.
Costs the same one hardware affine matrix shroud_cutout_sprite already spends on a scaled hole - a light that is both scaled and turned still shares that one matrix, never a second, and a light left at the default scale that only turns still costs just the one. The hardware only ever shows a rotated (or scaled) sprite at up to DOUBLE the size it was drawn at: a mask drawn 32x32 stays fully visible turning at any angle, up to 64x64 on screen, and whatever a rotation or an over-1 scale would need past that is clipped by the hardware itself, silently - no error, nothing this engine can catch for you. Draw the mask at the size its own turned shape needs, up to that ceiling (64x64 is the biggest a sprite can be drawn at all, so 128x128 is the hard limit nothing can pass). Everything else - the mask is never drawn, only its silhouette cuts the hole; `flicker` pulses the scale, never the mask’s frames; a room that is not shrouded leaves it inert; calling any attach call again replaces this instance’s own light - matches shroud_cutout_sprite exactly; see its own On the GBA note.